Bob and Alice are playing a game involving an infinite series of numbers: 1,2,3, …
However, there are some conditions:
Your task is to determine the smallest number n such that Alice and Bob can each pick their respective numbers from the infinite series without violating any conditions.
Example 1:
Input: a = 3, b = 2, c = 2, d = 3
Output: 5
Explanation: Alice can choose numbers not divisible by 2: {1, 3, 5}
Bob can choose numbers not divisible by 3: {2, 4}
The smallest number n such that Alice and Bob can each choose their respective numbers without overlap is 5.
Example 2:
Input: a = 4, b = 3, c = 3, d = 4
Output: 7
Constraints:
1 <= a, b <= 10^9
1 < c, d <= 1000
Test Cases
1test('TestCase1', () => {
2 expect(minNumberForPicks(3, 2, 2, 3)).toBe(5);
3});
1test('TestCase2', () => {
2 expect(minNumberForPicks(4, 3, 3, 4)).toBe(7);
3});
1test('TestCase3', () => {
2 expect(minNumberForPicks(3, 2, 3, 3)).toBe(7);
3});
Console